package seriable;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class People implements Serializable {
	private static final long serialVersionUID = 1L;

	private String name;
	private Salary salary;

	public People(String name, Salary salary) {
		this.name = name;
		this.salary = salary;
	}

	public People() {
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Salary getSalary() {
		return salary;
	}

	public void setSalary(Salary salary) {
		this.salary = salary;
	}

	private void writeObject(ObjectOutputStream out) throws IOException {
		System.out.println("writeObject");
		out.defaultWriteObject();
		out.writeDouble(salary.getBaseSalary());
	}

	private void readObject(ObjectInputStream in) throws IOException,
			ClassNotFoundException {
		System.out.println("readObject");
		in.defaultReadObject();
		salary = new Salary(in.readDouble());
	}

}


class TestPeople{
	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
//		SerializationUtil.writeObject(new People("¹С¹", new Salary(2800, 3000)));
		People peo = (People) SerializationUtil.readObject();
		System.out.println(peo.getName());
		System.out.println(peo.getSalary().getBaseSalary());
		System.out.println(peo.getSalary().getBound());
		
	}
}